/******************************************************************
 * Copyright (c) 2024 Bocloud Technologies Co., Ltd.
 * installer is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain n copy of Mulan PSL v2 at:
 *          http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 ******************************************************************/

package initialize

import (
	"gopkg.openfuyao.cn/bkecommon/cluster/api/v1beta1"
	"gopkg.openfuyao.cn/bkecommon/cluster/node"
)

func GetDefaultBKEConfig() *BkeConfig {
	cfg := &BkeConfig{
		Cluster: v1beta1.Cluster{
			ControlPlane: v1beta1.ControlPlane{
				ControllerManager: &v1beta1.ControlPlaneComponent{
					ExtraVolumes: nil,
				},
				Scheduler: &v1beta1.ControlPlaneComponent{
					ExtraVolumes: []v1beta1.HostPathMount{
						{
							Name:      "example",
							HostPath:  "/host/exam",
							MountPath: "/host/exam",
							ReadOnly:  true,
							PathType:  "Directory",
						},
					},
				},
				APIServer: &v1beta1.APIServer{
					APIEndpoint: v1beta1.APIEndpoint{
						Host: "",
						Port: int32(DefaultAPIBindPort),
					},
					ControlPlaneComponent: v1beta1.ControlPlaneComponent{
						ExtraArgs:    nil,
						ExtraVolumes: nil,
					},
					CertSANs: nil,
				},
				Etcd: &v1beta1.Etcd{
					DataDir: "",
					ControlPlaneComponent: v1beta1.ControlPlaneComponent{
						ExtraArgs:    map[string]string{},
						ExtraVolumes: nil,
					},
					ServerCertSANs: nil,
					PeerCertSANs:   nil,
				},
			},
			Kubelet: &v1beta1.Kubelet{
				ControlPlaneComponent: v1beta1.ControlPlaneComponent{
					ExtraArgs:    map[string]string{},
					ExtraVolumes: nil,
				},
				ManifestsDir: "",
			},

			Networking: v1beta1.Networking{
				ServiceSubnet: "",
				PodSubnet:     "",
				DNSDomain:     "",
			},
			KubernetesVersion: "",
			CertificatesDir:   "",
			NTPServer:         DefaultNTPServer,
			ImageRepo: v1beta1.Repo{
				Domain: "",
				Ip:     "",
				Port:   "",
				Prefix: "",
			},
		},
		Nodes: []v1beta1.Node{
			{
				IP:       "172.100.200.10",
				Port:     "22",
				Username: "root",
				Password: "*********",
				Hostname: "master-1",
				Role: []string{
					node.MasterNodeRole,
					node.EtcdNodeRole,
				},
			},
			{
				IP:       "172.100.200.11",
				Port:     "22",
				Username: "root",
				Password: "*********",
				Hostname: "master-2",
				Role: []string{
					node.MasterNodeRole,
					node.EtcdNodeRole,
				},
			},
			{
				IP:       "172.100.200.12",
				Port:     "22",
				Username: "root",
				Password: "*********",
				Hostname: "master-3",
				Role: []string{
					node.MasterNodeRole,
					node.EtcdNodeRole,
				},
			},
			{
				IP:       "172.100.200.13",
				Port:     "22",
				Username: "root",
				Password: "*********",
				Hostname: "worker-1",
				Role: []string{
					node.WorkerNodeRole,
				},
			},
			{
				IP:       "172.100.200.14",
				Port:     "22",
				Username: "root",
				Password: "*********",
				Hostname: "worker-2",
				Role: []string{
					node.WorkerNodeRole,
				},
			},
			{
				IP:       "172.100.200.15",
				Port:     "22",
				Username: "root",
				Password: "*********",
				Hostname: "worker-3",
				Role: []string{
					node.WorkerNodeRole,
				},
			},
		},
		Addons: []v1beta1.Product{
			{
				Name:    "kubeproxy",
				Version: "1.25.6",
				Param: map[string]string{
					"clusterNetworkMode": "calico",
				},
			},
			{
				Name:    "calico",
				Version: "v3.4.1",
				Param: map[string]string{
					"calicoMode": "bgp",
				},
			},
			{
				Name:    "coredns",
				Version: "v1.8.0",
			},
			{
				Name:    "nfs-csi",
				Version: "v4.1.0",
				Param: map[string]string{
					"nfsServer": "[your nfs server ip]",
				},
			},
			{
				Name:    "bocoperator",
				Version: "latest",
				Param: map[string]string{
					"boc.version":   "v4.0",
					"boc.nfsServer": "[your nfs server ip]",
				},
			},
			{
				Name:    "cluster-api",
				Version: "v1.3.2",
			},
		},
		CustomExtra: map[string]string{
			"containerd": "containerd-1.6.16-linux-{.arch}.tar.gz",
		},
	}

	SetDefaultBKEConfig(cfg)
	return cfg
}
